package ricky.loader
{
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import ricky.Interface.ILoadComplete;
	import ricky.Interface.ILoader;
	
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	/**
	 * 资源加载器
	 */
	public class MyUrlLoader extends URLLoader implements ILoader
	{
		private var _req:Request;
		private var _loadComplete:ILoadComplete;
		private var _tag:*;
		private var rulReq:URLRequest;
		public function MyUrlLoader(request:URLRequest=null)
		{
			super(request);
		}
		
		public function set req(value:Request):void
		{
			_req = value;
			this.dataFormat=URLLoaderDataFormat.BINARY;
			rulReq=new URLRequest(req.url);
			
		}
		
		public function get getData():*
		{
			return this.data;
		}
		
		
		public function beginLoad():void
		{
			this.load(rulReq);
		}

		/**
		 * 数据缓存
		 */
		public function get tag():*
		{
			return _tag;
		}

		/**
		 * @private
		 */
		public function set tag(value:*):void
		{
			_tag = value;
		}

		/**
		 * 当前请求
		 */
		public function get req():Request
		{
			return _req;
		}


		/**
		 * 加载完成后回调接口
		 */
		public function get loadComplete():ILoadComplete
		{
			return _loadComplete;
		}

		/**
		 * @private
		 */
		public function set loadComplete(value:ILoadComplete):void
		{
			_loadComplete = value;
		}

	}
}